
insertStyle(funString(function(){/*
.slide-show-header h2 {
width: 250px !important;
}
#MiDownFileButtom{
	border: 1px #ff6000 solid;
padding-left: 0;
background: -webkit-linear-gradient(top,#ff8000,#ff6000);
height: 30px;
line-height: 30px;
margin:4px 0;
margin-right: 10px; 
border-radius:3px;
}
#MiDownFileButtom:active{
	background: -webkit-linear-gradient(top,#ff6000,#ff8000);
}
#MiDownFileButtom b{
	padding: 0 10px;
	background: none;
	height: 30px;
line-height: 30px;
color:#fff;
}

.down-xm{
	-webkit-filter: hue-rotate(170deg) saturate(2);
}
*/}));



var viewurl = "http://pan.baidu.com/wap/view?fsid="



var btn = '<a class="new-dbtn" hidefocus="true" href="javascript:;" id="MiDownFileButtom">'+
'<b>下载到小米路由</b>'+
'</a>';
var btn2 = '<a node-type="btn-item" data-key="download" class="btn download down-xm" href="javascript:;"></a>';
var btn3= '<li style="display: list-item;" class="rcm-xmd"><a hidefocus="true" href="javascript:;" class="list-node" node-type="item download" data-key="download">下载到小米</a></li>';

src = getURI();
$(function(){

	$(document).on("mouseover",".item",function(){
		var extname = $(this).attr('data-extname');
		if(extname!='dir' && extname!='shoucang' && extname!='yingyong'){
			if($(this).find('.down-xm').length==0){
				$(this).find('.download').after(btn2);
				$(this).find('.down-xm').click(function(){
					var fsid = $(this).parents('.item').attr('data-id');
					fsid_download(fsid);
					return !1;
				});
			}
		}else{
			$(this).find('.down-xm').remove();
		}
	});
    $('body').mouseup(function(){
        setTimeout(function(){
            if($('.rcm-xmd').length==0&&$('.menu-main').length!=0){
                $('.menu-main').append(btn3);
                $('.rcm-xmd').click(function(){
                    mi.download_event('',src,function(){});
                });
            }
        },200);
    });
});



function fsid_download(fsid){
	var iframe = $('<iframe>')
		.attr('id','fd'+fsid)
		.attr('src',viewurl+fsid)
		.on("load",function(){
			console.log(this.contentWindow.document);
       	var iiframe = this.contentWindow.document;
       	var sto = function(){
			var href = $('#fileDownload',iiframe).attr('href');
			console.log(href);
			var name = $('#fileName',iiframe).attr('data-fn');
			if(!href){
				setTimeout(sto,1000);
			}else{
				console.log(href);
				mi.download_url(href,name,getURI());
			}
		}
		sto();
    });
	$('body').append(iframe);
}





$('#downFileButtom').after(btn);
var downFileButtomname = $('.slide-show-header .ellipsis').text();
$('#MiDownFileButtom').click(function(){
	mi.download_event(downFileButtomname,src,function(){$("#downFileButtom").get(0).click();});
})